<?php
namespace App\Http\Controllers;

use App\Services\RequestService;
use Dingo\Api\Routing\Helpers;
use Aitifen\Library\Common\MicroService\Client;
use Illuminate\Http\Request;
use Aitifen\Library\Xxtea\Xxtea;
use Illuminate\Support\Facades\Config;
use App\Http\Controllers\Controller;

class WebController extends Controller
{
    protected $appKey;
    protected $appSecret;
    public $token;
    /**
     *  加载appkey,appsecret,accesstoken
     */
    public function __construct(Request $request)
    {
        $token   = isset($_COOKIE['STEAM-ACCESS-TOKEN']) ? $_COOKIE['STEAM-ACCESS-TOKEN'] : '';
        $appData = isset($_COOKIE['app_data']) ? $_COOKIE['app_data'] : '';

        if (empty($token)) {
            $token   = $request->header('STEAM-ACCESS-TOKEN');
        }
        $this->token = $token;

        //app_key|app_secret设置
        if (isset($appData) && !empty($appData)) {
            $appData = Xxtea::decrypt($appData, Config::get('common.cookie_encrypt_key'),true);
            $this->appKey    = $appData['app_key'];
            $this->appSecret = $appData['app_secret'];
        }
    }


}
